using UnityEngine;

[ExecuteInEditMode]
public class UVOffsetArray : MonoBehaviour
{
	private int _lastIndex;

	public float Index;

	private bool _isUseUV2;

	public bool IsUseUV2;

	public UVOffsetTracker[] Trackers;

	private void Start()
	{
		if (!Application.isPlaying && Trackers != null)
		{
			Trackers = null;
		}
		_lastIndex = -1;
		if (Trackers == null || Trackers.Length == 0)
		{
			Trackers = GetComponentsInChildren<UVOffsetTracker>();
		}
	}

	private void Update()
	{
		int num = Mathf.RoundToInt(Index);
		if (num == _lastIndex && IsUseUV2 == _isUseUV2)
		{
			return;
		}
		_lastIndex = num;
		_isUseUV2 = IsUseUV2;
		for (int i = 0; i < Trackers.Length; i++)
		{
			if (Trackers[i] != null)
			{
				Trackers[i].SetIndex(_lastIndex, _isUseUV2);
			}
		}
	}
}
